﻿using System;
using System.Windows.Data;
using System.Windows.Input;

namespace Hibiku.ValueConverters
{
    [ValueConversion(typeof(string), typeof(string))]
    public class StringToLengthConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var text = value as string;

            return "" + (string.IsNullOrEmpty(text) ? 0 : text.Length);
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
